Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to handle Rundeck environment variables and options for execution in pod #161

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

greenmath
Copy link

I like to improve the script and command execution in pods in the way, that the environment variables set by Rundeck like the possible options of a job, are propagated to the pod. And create with this a behavior like running jobs on the local machine. For this, I wrote two functions.

  • common.handle_rundeck_environment_variables: This function is called in pods-run-script.py and pods-node-executor.py. In the function all environment variables of the current Rundeck process are filtered for just variables where the key starts with RD_. Also the function looks for variables that starts with RD_FILE_ that are uploaded files. This files are needed to uploaded to the pod too. The default directory is /tmp or what in RD_NODE_FILE_COPY_DESTINATION_DIR is defined.
    The function returns two arrays. The first array including all environment variables and can be added in front of the execution command. The first element is the command env and the following elements in the array are strings in the format 'key=value'. The second array contains all paths of uploaded files. This array can be used for my second function.

  • common.clean_up_temporary_files: This function is called in the end of pods-run-script.py and pods-node-executor.py. Like the name says the function delete uploaded files from the pod.
    In the pods-run-script function the temporary created script is added to the list of to deleting files.

My Background:
I like to use Rundeck in a kind “as a service” for multiple departments in my organization. To separate the environment of every department I like to use pods in my k8s. With this separation the departments can’t break or delete setups from other departments. But to use pods like running jobs on the local Rundeck machine it is needed to also have all Rundeck environment variables and uploaded files inside the pod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant